{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading weights from local directory\n"
     ]
    }
   ],
   "source": [
    "import torch\n",
    "from ltp import LTP\n",
    "\n",
    "ltp = LTP(\"/Users/lazyben/Downloads/small\")  # 默认加载 Small 模型\n",
    "\n",
    "# 将模型移动到 GPU 上\n",
    "if torch.cuda.is_available():\n",
    "    # ltp.cuda()\n",
    "    ltp.to(\"cuda\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[['牛奶', '当中', '含有', '蛋白质', '、', '钙', '、', '铁', '、', '维生素A', '、', '维生素B2', '等', '多种', '营养素', '。']]\n",
      "[{'head': [2, 3, 0, 15, 6, 4, 8, 4, 10, 4, 12, 4, 4, 15, 3, 3], 'label': ['ATT', 'SBV', 'HED', 'ATT', 'WP', 'COO', 'WP', 'COO', 'WP', 'COO', 'WP', 'COO', 'RAD', 'ATT', 'VOB', 'WP']}]\n"
     ]
    }
   ],
   "source": [
    "result = ltp.pipeline([\"牛奶当中含有蛋白质、钙、铁、维生素A、维生素B2等多种营养素。\"], tasks = [\"cws\",\"dep\"])\n",
    "    \n",
    "# output = ltp.pipeline([\"他叫汤姆去拿外衣。\"], tasks=[\"cws\", \"pos\", \"ner\", \"srl\", \"dep\", \"sdp\"])\n",
    "# 使用字典格式作为返回结果\n",
    "print(result.cws)\n",
    "print(result.dep)  # print(output[0]) / print(output['cws']) # 也可以使用下标访问"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "from tqdm import tqdm\n",
    "import json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "芦丁具有强化血管的功效，能预防动脉硬化和高血压。\n",
      "芋头含有钾\n",
      "**************************************************\n",
      "芋头中含有丰富的钾，它能排出体内多余盐分，具有预防高血压的功效。\n",
      "**************************************************\n",
      "牡蛎是锌的重要供给源。\n",
      "**************************************************\n",
      "可平放在筛网上，放于通风阳光充足处晾晒。或取长的棉绳捆绑香菇蒂头处，再把棉绳吊挂起来让其风干。\n",
      "**************************************************\n",
      "黄酮素能增加骨密度，预防骨质疏松症。\n",
      "**************************************************\n",
      "关于鱼、禽、蛋、肉等动物性食物，大多数国家将它们归为一个食物组进行推荐，只有6个国家单独对畜禽肉进行推荐，并建议每日不超过90g;\n",
      "**************************************************\n",
      "过多摄入含糖饮料可增加成人2型糖尿病的发病风险。\n",
      "全谷含有植酸\n",
      "**************************************************\n",
      "全谷、杂粮豆类中含有较高水平的植酸，不少人担心食用过多会影响钙、铁等的吸收，发生缺钙、贫血等不良问题。\n",
      "**************************************************\n",
      "牛蒡中膳食纤维含量很高，其中的菊糖能增加肠道益生菌的数量，刺激肠道蠕动，调整肠道功能。\n",
      "**************************************************\n",
      "西兰花营养丰富，富含蛋白质、碳水化合物、脂肪、矿物质、维生素C和胡萝卜素等，可有效调节人体酸碱平衡，有助于骨骼健康。\n",
      "**************************************************\n",
      "茄色苷属于多酚，分布于茄子皮中，有着很强的抗氧化作用，能预防癌症。\n",
      "**************************************************\n",
      "另一方面，由于膳食不平衡造成老年人肥胖以及营养相关慢性疾病问题依然严峻，老年人肥胖率为13.0%，高血压患病率近60%，糖尿病患病率近15%。\n",
      "**************************************************\n",
      "海带含有大量的不饱和脂肪酸，能清除附着在血管壁上的过多胆固醇；海带含有的昆布素等多糖可降低血清胆固醇和甘油三酯的含量。\n",
      "**************************************************\n",
      "优质的香菇一般体圆齐正、菌伞肥厚、菌伞下面的褶紧密细白，并且可闻到一股独特的香味。\n",
      "**************************************************\n",
      "花青素能改善循环系统，促进皮肤健康。\n",
      "**************************************************\n",
      "增加全谷物的消费，减少精白米面的摄入；在保证充足蔬菜摄入的前提下，强调增加深色蔬菜的消费比例；增加新鲜水果的摄入；增加富含优质蛋白质的豆类及其制品摄入。\n",
      "**************************************************\n",
      "牛磺酸还能促进胆汁酸的分泌，乳化食物中的脂防，使人体更容易吸收，具有减肥功效。\n",
      "**************************************************\n",
      "便秘患者应当远离辣椒、芥末、酒等辛辣刺激性食物。这些食物易使人上火，消耗体液，使大便干硬，加重便秘。\n",
      "**************************************************\n",
      "黄豆及其制品所提供的优质蛋白质可以媲美动物性蛋白质，应成为素食人群获取蛋白质的主要途径。\n",
      "**************************************************\n",
      "食用魔芋能降低血糖值和胆固醇值，具有预防糖尿病和脂质异常的作用。\n",
      "**************************************************\n",
      "菌藻类包含干木耳、干海带、干紫菜、干蘑菇畜禽肉类：牛肉、猪肉、鸡肉、鸭肉\n",
      "**************************************************\n",
      "体内中的镁约有60%存在于骨骼当中，剩余的分布于肌肉、肝脏、血液当中。镁还参与了300多种酶的反应。\n",
      "**************************************************\n",
      "因此，食用沙丁鱼能有效预防肥胖、贫血以及动脉硬化等症状\n",
      "**************************************************\n",
      "长时间煮炖减少胆固醇。猪肉经长时间炖、煮后，不饱和脂肪酸增加，胆固醇含量会大大降低，尤其适合血脂高、血压高的人。\n",
      "**************************************************\n",
      "高血压患者忌酒。酒不仅会使血压升高，而且会增加热量的摄入，还会引起体重增加，降低抗高血压药物的效果，所以高血压患者应远离酒精。\n",
      "COO\n",
      "COO\n",
      "**************************************************\n",
      "另外，黄豆还含有卵磷脂、丰富的维生素及其他矿旷物质，特别适合脑力工作者。\n",
      "**************************************************\n",
      "多酚类色素、类胡萝卜素这类化合物具有抗氧化作用，可以抗衰老，对疾病也有很好的预防作用。\n",
      "**************************************************\n",
      "植物性食物中铁的吸收率较低，还容易受到植酸、草酸等因素的干扰。\n",
      "**************************************************\n",
      "芹菜可以和豆腐干等一起炒着，吃营养好，也可以凉拌。\n",
      "**************************************************\n",
      "在血糖控制好的情况下，可适当吃苹果，苹果中的维生素C、钾、膳食纤维能促进脂肪分解，预防肥胖，还能预防糖尿病并发高血压等并发症。\n",
      "**************************************************\n",
      "当添加糖摄入量<5%能量（约25g)时，龋齿发病率显著下降。\n",
      "**************************************************\n",
      "笋尖鳞片抱合紧凑，无收缩即为较好的鲜嫩芦笋，反之不鲜嫩。将芦笋用双手折断，较脆、易折断、笋皮无丝状物为鲜嫩，反之不鲜嫩。\n",
      "**************************************************\n",
      "比如，不可溶性膳食纤维（可溶性和不可溶性膳食纤维对延缓餐后的血糖升高均有效)主要存在于谷物的表皮中。\n",
      "**************************************************\n",
      "膳食纤维能促进排便预防便秘，对预防结肠癌具有显著的功效。\n",
      "**************************************************\n",
      "肥胖患者建议摄取膳食纤维。它能减缓防止内脏脂肪的堆积。\n",
      "**************************************************\n",
      "便秘的并发并发症：直肠炎、肛裂、痔疮\n",
      "**************************************************\n",
      "超重肥胖的青少年做到食物多样化，适当多吃杂粮、蔬菜水果及豆制品；同时合理安排三餐，避免零食和含糖饮料。\n",
      "**************************************************\n",
      "系统综述显示，与不饮酒者相比，每天酒精摄入50g和100g以上可增加结直肠腺瘤发病风险16%和61%。\n",
      "**************************************************\n",
      "高盐（钠）摄入可增加胃癌的发病风险。\n",
      "芝麻含有亚油酸\n",
      "**************************************************\n",
      "芝麻中含有不饱和脂肪酸的亚油酸。芝麻素是芝麻中的特有成分，它是芝麻准木质素的一种，有着很强的抗氧化作用。\n",
      "**************************************************\n",
      "青椒的绿色是因为青椒中含有一种名叫叶绿素的天然色素。\n",
      "**************************************************\n",
      "针眼患者需要食用鳗鱼和胡萝卜等食物，摄取能够保护眼晴健康的维生素A\n",
      "**************************************************\n",
      "润肠通便、排毒，宜生吃。生吃胡萝卜容易让其中的水溶性维生素和矿物质被人体吸收，所以喝鲜榨的胡萝卜汁，可以起到润肠通便、排毒的作用。\n",
      "**************************************************\n",
      "胡萝卜素还能抗衰老，预防花粉症以及环境污染物质给身体带来的伤害。\n",
      "**************************************************\n",
      "白萝卜辣味成分中的异硫氰酸盐也具有防止血栓以及解毒等功效。\n",
      "**************************************************\n",
      "由于不饱和脂肪酸极易氧化，食用它们时应适量增加维生素E的摄入量。\n",
      "**************************************************\n",
      "眼睛疲劳需要补充“眼睛的维生素”一维生素A。\n",
      "**************************************************\n",
      "代表性的例子是被称为“第六营养素”的膳食纤维。\n",
      "**************************************************\n",
      "维生素B2能防止痤疮和皮肤干燥\n",
      "**************************************************\n",
      "豇豆所含的B族维生素能维持正常的消化腺分泌和肠胃蠕动功能，可帮助消化，防治慢性胃炎。\n",
      "**************************************************\n",
      "通常将小米放在阴凉、干燥、通风较好的地方。储藏前水分过大时，不能曝晒，可阴干。\n",
      "**************************************************\n",
      "也可在白开水中加入一些新鲜梨汁，对润肺止咳大有好处。\n",
      "**************************************************\n",
      "爱吃面食的人，可在精白面粉中加些玉米面、黄豆粉、紫薯粉等。粗粮尽管有很多好处，但是也不要走极端，只吃粗粮放弃细粮也是不行的，粗细结合才是最好的。\n",
      "**************************************************\n",
      "将鸡蛋对光，如果看到鸡蛋明亮通透则新鲜度高。鸡的种类不同，蛋壳的颜色也就不同，但营养价值并没有太大差异。\n",
      "**************************************************\n",
      "2013年40岁以上人群脑卒中患病率为2.1%，糖尿病、高血压、心脑血管疾病等慢性病均呈上升的态势。这些慢性病与长期膳食不平衡和油盐摄入过多密切相关。\n",
      "**************************************************\n",
      "特别是农村居民的膳食结构得到较大的改善，碳水化合物的供能比从1992年的70.1%下降到2015年的55.3%，动物性食物提供的蛋白质从1992年的12.4%提高到2015年的31.4%，城乡差距逐渐缩小。\n",
      "裙带菜含有膳食纤维\n",
      "**************************************************\n",
      "裙带菜中含有膳食纤维，具有改善便秘和降血压的作用。\n",
      "**************************************************\n",
      "牛奶当中含有蛋白质、钙、铁、维生素A、维生素B2等多种营养素。\n",
      "**************************************************\n",
      "钾在人体中的作用：与细胞外液的钠合作，调节渗透压；与细胞的新陈代谢有关，参与热量代谢，一定浓度的钾，可维持细胞内一些酶的活性；维持神经肌肉系统的正常功能，维持心肌正常功能。\n",
      "**************************************************\n",
      "鲑鱼中维生素D含量丰富，有助于人体对钙质的吸收，搭配牛奶也能提高人体对牛奶的吸收率。\n",
      "**************************************************\n",
      "黑芝麻及羊栖菜等食物中富含的神经酰胺能保持皮肤滋润，有效缓解皮肤干燥。\n",
      "**************************************************\n",
      "食用纳豆时，充分搅拌能增强纳豆菌活力，增强溶解血栓的功效。\n",
      "**************************************************\n",
      "轻微的缺水不会引起严重疾病，但会影响身体健康，如引起口干舌燥、便秘、皮肤缺乏弹性、心悸、头晕、疲惫等。同样的，当出现这些状况并有尿少、尿色深黄等现象时，也是提醒你身体处于缺水状态了。\n",
      "**************************************************\n",
      "薏米性偏寒，做饭时，可加点大米、黑米、紫米、糙米等五谷，既可养胃，又能控血糖。\n",
      "**************************************************\n",
      "山药要选择茎干笔直、粗壮，拿到手里有一定分量的。如果购买的是切好的山药，要仔细辨认切口处是否新鲜，颜色是否自然。\n",
      "**************************************************\n",
      "饮用玫瑰花茶、菊花茶、桃花茶等，可以补水、抗氧化、降脂，前提是泡淡一点，不要放很多冰糖或蜂蜜，以免有增肥风险\n",
      "**************************************************\n",
      "盐水浸泡。可以先把葡萄皮上的浮尘洗干净，然后把脏水倒掉，把葡萄浸入溶解食盐的清水里浸泡20分钟，再轻揉搓洗，尤其注意把果蒂部的污物清洗干净，再用清水冲洗就可以了。\n",
      "**************************************************\n",
      "这些方法对超重、肥胖人群有一定的作用，或作为某些疾病辅助性治疗，但并不适用于所有人，特别是青少年、孕妇、老人，尚没有研究证据显示长期的健康效益。\n",
      "**************************************************\n",
      "红豆洗净，放入沸水中，再次烧开，继续煮3~5分钟关火，浸泡30分钟后再次开火，再煮10分钟左右就可以煮烂了。这种方式煮熟的红豆，营养损失少而且比较节省燃气。\n",
      "**************************************************\n",
      "B族维生素有助于增强视神经功能，预防视力下降以及眼睛疲劳。\n",
      "**************************************************\n",
      "红豆长期保存可先浸泡，红豆在开水中浸泡十几分钟后，捞出晒干，储存在密闭、干燥容器中，可长时间不变质、不生虫。\n",
      "**************************************************\n",
      "鳝鱼性温，不适合热性体质的人，比如风热感冒、上火的人最好少吃，高血压、卒中后遗症、甲亢及急性炎症患者均不宜食用过多。\n",
      "**************************************************\n",
      "眼睛疲劳，推荐补充维生素A合花青素\n",
      "**************************************************\n",
      "弛缓性便秘由于肠道蠕动弱、粪便移动速度慢而引起，应补充不溶性膳食纤维含量多的食物，如全麦、谷物、豆类、根茎类、果皮、胡萝卜、柑橘等。\n",
      "**************************************************\n",
      "另外，摄取充足的维生素C和维生素E也可以有效缓解肌肉疼痛。\n",
      "**************************************************\n",
      "血脂异常患者应该增加膳食纤维的摄入。增加粗粮、豆类、薯类等富含膳食纤维的食物的摄入，可减少对食物中脂肪的吸收。\n",
      "**************************************************\n",
      "芹菜焯水时，最好整棵焯水后再切，这样能减少营养素的流失。\n",
      "罗勒含有β-胡萝卜素\n",
      "**************************************************\n",
      "罗勒中含有丰富的β-胡萝卜素，具有很强的抗氧化能力，能防止衰老。\n",
      "**************************************************\n",
      "水、B族维生素、维生素C、钙、不饱和脂肪酸是腹泻患者必须补充的营养素\n",
      "**************************************************\n",
      "长期食用大豆能舒预防更年期障碍和癌症。\n",
      "**************************************************\n",
      "维生素A推荐摄入量：男性每天800微克；女性每天700微克。\n",
      "**************************************************\n",
      "水果中含有碳水化合物、膳食纤维、维生素C、钾、镁、植物化合物等营养素\n",
      "**************************************************\n",
      "铜能促进铁的吸收与代谢\n",
      "COO\n",
      "COO\n",
      "**************************************************\n",
      "它包括β-胡萝卜素、番茄红素和辣椒素等。β-胡萝卜素和番茄红素可以预防癌症，辣椒素可以促进血液循环。\n",
      "**************************************************\n",
      "腹泻患者补水很关键\n",
      "**************************************************\n",
      "刺激性强的调味品如咖喱粉、胡椒粉、辣椒粉等，会导致呼吸道黏膜干燥、痉挛，引起鼻塞、呛咳等，加重病人的症状，感冒患者勿食。\n",
      "**************************************************\n",
      "β-胡萝卜素富含于胡萝卜、菠菜等蔬菜中。\n",
      "**************************************************\n",
      "β-葡聚糖还具有提高人体免疫功能、抑制癌细胞增殖的功效。\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**************************************************\n",
      "黄瓜含有维生素C,可促进糖代谢，其所含的丙醇二酸能有效抑制糖类转变成脂肪。\n",
      "**************************************************\n",
      "冠心病患者应该多吃蔬菜、水果。蔬菜、水果是维生素、矿物质、膳食纤维的很好来源，能降低人体对胆固醇的吸收，有利于降低血液黏稠度，提高血管通透性。\n",
      "**************************************************\n",
      "维生素C可防止皮肤粗糙\n",
      "**************************************************\n",
      "维生素C促使胶原蛋白合成，抑制黑色素生成。从而防止皮肤出现色斑及老化，是美容养颜必不可少的维生素\n",
      "**************************************************\n",
      "豆腐皮中的蛋氨酸不仅是神经传导物质的合成原料，还能提高肝脏的解毒作用，强化肝脏功能。\n",
      "**************************************************\n",
      "竹荚鱼中富含名为EPA的不饱和脂肪酸，能减少人体血液中的胆固醇，还具有防止血栓的作用。\n",
      "**************************************************\n",
      "荞麦、洋葱、芹菜、黄豆、番茄、茄子能有缓解高血压\n",
      "**************************************************\n",
      "维生素B2主要存在于动物性蛋白中，如蛋黄、肝、肾、瘦肉等；绿叶蔬菜、茶中含有丰富的叶酸，平时只要注意多吃动物蛋白和绿叶蔬菜，适当喝茶，就可以提供身体所需要的维生素B2和叶酸。\n",
      "**************************************************\n",
      "值得一提的是，蛳鱼背部中含有丰富的牛磺酸，能强化肝脏功能、缓解疲劳。\n",
      "**************************************************\n",
      "反式脂防摄入过多可导致心血管疾病死亡风险升高。\n",
      "**************************************************\n",
      "竹荚鱼中丰富的DHA能促进大脑发育。\n",
      "**************************************************\n",
      "维生素E、维生素C、B一胡萝卜素等抗氧化能力强的食物在抗衰老、预防动脉硬化等方面发挥着重要作用。\n",
      "**************************************************\n",
      "这是因为这些食物每日可以进食较大的量，而肉类、鱼类虽然也可以提供钾，却不适合多吃，否则有引发肥胖、“三高”等疾病的隐患。\n",
      "**************************************************\n",
      "豆腐是豆类蛋白含量最高的食物，能够降低胆固醇，还能减少妇女更年期的潮热反应，同时使骨骼健肚。\n",
      "**************************************************\n",
      "便秘患者需要补充B族维生素、膳食纤维、不饱和脂肪酸、水\n",
      "**************************************************\n",
      "富含花青素的食物有蓝莓、葡萄、红紫苏、茄子等蔬果。\n",
      "**************************************************\n",
      "熏制食品的摄入可增加食管癌的发病风险。\n",
      "**************************************************\n",
      "保持头发健康必不可缺是B族维生素，有助于糖类、脂质和蛋白质代谢，对头发与皮肤的健康尤为重要。\n",
      "**************************************************\n",
      "从膳食指南可知，世界上绝大部分国家推荐摄入新鲜多样的蔬菜水果，适量摄入鱼、禽、蛋、肉等动物性食物，限制油脂、盐、糖和酒精等的摄入，并鼓励大量饮水。\n",
      "**************************************************\n",
      "胡萝卜叶中所含维生素A是根部的两倍，还含有大量的膳食纤维。\n",
      "**************************************************\n",
      "大多数国家鼓励更多蔬菜和水果的摄入，饮食多样化，限制盐、糖、油和酒精的摄入，建议保持健康体重，并确保摄入足够的水。\n",
      "**************************************************\n",
      "2012年，WH0对72878例成年人群的队列研究进行系统评价显示，与对照组相比，高钠摄入组患脑卒中风险增加24%，脑卒中死亡率增加63%。\n",
      "**************************************************\n",
      "老鸭汤滋五脏之阴，但老鸭肉在短时间内不容易煲烂，可以在锅里放一些木瓜皮，木瓜皮的酶会加速鸭肉熟烂。\n",
      "**************************************************\n",
      "贫血患者也要摄取青椒、西蓝花等蔬菜中丰富的叶酸\n",
      "**************************************************\n",
      "食物过敏其症状为荨麻疹、恶心、腹痛、腹泻、呼吸困难，严重的还可能使人休克等。\n",
      "**************************************************\n",
      "胡萝卜含有丰富的B-胡萝卜素，在体内能够转化为维生素A,能帮助保持眼睛的润滑及透明度，促进眼睛的健康。\n",
      "**************************************************\n",
      "与此同时，农村居民膳食相关慢性病的发病率也出现快速增长趋势。\n",
      "**************************************************\n",
      "蛋白质是生命的物质基础，没有蛋白质就没有生命。\n",
      "**************************************************\n",
      "骨质疏松患者应该积极使用富含钙的食物，骨质疏松的主要症状：腰背痛、身高缩短、驼背、易骨折、胸闷气短，有以下的常见并发症：骨折、驼背、关节疼痛。\n",
      "**************************************************\n",
      "西瓜皮和红色果肉之间的白色部分含有大量瓜氨酸，它是氨基酸的一种。人体摄入后能消除身体水肿，促进血液流通，维持体温。建议吃完果肉后不要扔掉这部分，可以进行腌制或做成沙拉食用。\n",
      "**************************************************\n",
      "比如八宝饭+鲫鱼豆腐汤+胡萝卜西蓝花炒山药+苹果。\n",
      "**************************************************\n",
      "腹泻患者应当及时补充水分。腹泻会造成水分流失，严重时甚至脱水，所以腹泻期间一定要及时补充水分，可以选择生理盐水、果汁或菜汤。\n",
      "**************************************************\n",
      "冠心病患者需要避免饱和脂肪酸摄入过多。饱和脂肪酸是影响血脂的最主要因素，会导致血清总胆固醇和低密度脂蛋白胆固醇（坏胆固醇）水平的升高，要尽可能少地摄取饱和脂防酸(<总热量的10%)。同时，增加不饱和脂肪酸（鱼、禽类等）的摄入能降低胆固醇。\n",
      "**************************************************\n",
      "每天摄入25~30克膳食纤维，有利于痛风的康复。\n",
      "**************************************************\n",
      "生藕与熟藕的营养区分：莲藕生吃，比如凉拌，可清热解毒、润肺、凉血行瘀；做熟的藕性由寒变温，可健脾开胃、益血止泻；\n",
      "明日叶含有查耳酮\n",
      "**************************************************\n",
      "明日叶的液汁含有查耳酮，能改善便秘。而且还具有抗氧化作用，能预防癌症。\n",
      "**************************************************\n",
      "吃苹果时会尝到酸味，这是因为苹果中含有苹果酸和柠檬酸等有机酸，人体摄入后能消除疲劳。\n",
      "**************************************************\n",
      "核桃一直是我国传统医学常用的药食两用佳品，营养丰富，具有安神健脑的作用，有利于安抚更年期综合征患者的烦躁情绪，促进睡眠。\n",
      "**************************************************\n",
      "脂肪肝患者适量饮水，以促进身体新陈代谢。不要用饮料、牛奶、咖啡代替水。\n",
      "**************************************************\n",
      "每天吃7颗中等大小的草莓就能满足1天必要的维生素C摄取量。\n",
      "**************************************************\n",
      "一方面，有一部分老年人存在能量或蛋白质摄入不足，维生素B,、维生素B,、叶酸、钙镊入不足的比例均高于80%，80岁以上高龄老年人低体重率为8.3%，贫血率达到10%，农村老年人营养不足问题更为突出。\n",
      "**************************************************\n",
      "鸡腿菇能解决便秘问题，防止血压上升\n",
      "**************************************************\n",
      "高盐（钠）摄入能够增加高血压的发病风险，而降低盐（钠）摄入能够降低血压水平。\n",
      "**************************************************\n",
      "燕麦富含可溶性膳食纤维，可促进肠胃蠕动，减少胆固醇的吸收。\n",
      "**************************************************\n",
      "葡萄、番茄、南瓜等果蔬都有着赏心悦目的色彩，这些色彩的形成其实都来自植物化学物。\n",
      "**************************************************\n",
      "黄豆富含亚油酸、不饱和脂肪酸，均具有降低血液中胆固的作用，可减少动脉硬化的发生，预防高血压、冠心病等疾病。\n",
      "**************************************************\n",
      "黄豆蛋白质的氨基酸组成和动物蛋白质类以，其中氨基酸比较接近人体需要的比值，容易被消化吸收，有益于补充人体骨骼所需的蛋白质。\n",
      "**************************************************\n",
      "生吃青椒能摄取到比柠檬中含量更多的维生素C。\n",
      "**************************************************\n",
      "动物性食物以猪肉和鱼虾类为主，鱼虾类摄入相对较高，猪肉摄入量低；烹饪清淡少油少盐，比较接近理想膳食模式。\n",
      "**************************************************\n",
      "类胡萝卜素还能防止紫外线带来的刺激，预防老人斑和雀斑，具有美容养颜的功效。\n",
      "**************************************************\n",
      "与肉同煮时，后放冬瓜。瓜与肉煮汤时，冬瓜必须后放，然后用小火慢炖，这样可以防止冬瓜过熟过烂，营养元素也能得到较好的保存。\n",
      "**************************************************\n",
      "植物油能改善高胆固醇和高血压症状\n",
      "**************************************************\n",
      "老龄化已经是不可回避的社会问题，在我国一些省市，65岁以上的老龄人已超过20%预计到2025年，中国老年人口将突破3亿。\n",
      "**************************************************\n",
      "牛奶和豆浆中的水分含量很高，还可以提供蛋白质、钙等营养成分，又能解饿。但是不能把牛奶和豆浆当水喝，否则容易摄入过多的脂肪，引发健康隐患\n",
      "**************************************************\n",
      "但是在一些地中海国家如西班牙，考虑到红酒对心血管的保护作用，提出适量饮酒是有益的。\n",
      "**************************************************\n",
      "茄子富含芦丁，可增加毛细血管韧性和弹性，减小血管阻力，保证血液流通，避免血管破裂，进而降低血压。\n",
      "**************************************************\n",
      "考虑到有些肉类质地紧密，不容易嚼碎，消化能力差的人不妨把瘦肉、鸡心、鸭胗等剁碎，把排骨炖烂，这样更有助于消化。\n",
      "**************************************************\n",
      "经过这样处理的海带，无论是炒着吃、拌着吃或是炖汤，都非常容易煮烂，不会有咀嚼困难的困扰，同时也除去了腥味，口感特别好。\n",
      "**************************************************\n",
      "煮牛奶温度不宜过高。煮牛奶到温热即可，加热以60~70℃适宜。用煤气灶煮牛奶，用大火快热，锁住营养物质。用微波炉热牛奶，牛奶要倒入加热容器内，再进行加热。\n",
      "裙带菜含海藻酸\n",
      "**************************************************\n",
      "裙带菜中含丰富的海藻酸，可以给予肠道温和的刺激，促进排便。\n",
      "**************************************************\n",
      "维生素能促进营养素的吸收和代谢，是构成代谢所必需的辅助因子。\n",
      "**************************************************\n",
      "猪肉中维生素B的含量是糙米的2倍，是人体重要的维生素B摄取来源。\n",
      "**************************************************\n",
      "备孕女性应该多吃富含叶酸的食物：橘子、橙子、柠檬、葡萄柚等、菠菜、西蓝花、芦笋、莴笋、油菜等、大豆及豆制品、花生(花生酱人葵花子等、大麦、米糠、小麦胚芽、糙米等、动物肝脏、牛奶及乳制品\n",
      "**************************************************\n",
      "烹调用油可以为人体提供能量，促进脂溶性维生素如维生素A、维生素D、维生素E等的吸收，但是摄入过多血管容易被淤积的油脂等堵住，引起血脂异常、动脉硬化等心血管疾病，还会导致肥胖、脂肪肝、糖尿病等慢性病。\n",
      "**************************************************\n",
      "《中国居民膳食指南(2016)》建议食用油每人每天摄入25~30克，这个量具体是多少呢？\n",
      "**************************************************\n",
      "便秘患者应当适量食用含不饱和脂肪酸(25~30克)的食物。\n",
      "**************************************************\n",
      "增加饮水可降低肾脏及泌尿系统感染的发生风险。\n",
      "**************************************************\n",
      "对风寒引起的感冒，生冷性凉的瓜果应忌食。\n",
      "**************************************************\n",
      "慢性胃炎患者需要饮食应清淡、易消化。\n",
      "**************************************************\n",
      "海带能促进三大营养素的代谢，增加身体活力，还能燃烧脂肪，促进儿童生长发育。\n",
      "**************************************************\n",
      "应该有谷类、豆制品类、奶类、蛋类、肉类、蔬菜、水果等，使食物蛋白质中的8种必需氨基酸组成比例趋于平衡，营养互补。\n",
      "**************************************************\n",
      "章鱼具有高蛋白而又低脂肪、低能量，因此不易被人体消化，有助于减肥。\n",
      "**************************************************\n",
      "顺产产妇6周后可以进行有氧运动如散步、慢跑等。一般可从每天15分钟，逐渐增加至每天45分钟，形成规律。对于剖宫产的产妇，应根据自己的身体状况，缓慢增加有氧运动的强度及力量训练。\n",
      "**************************************************\n",
      "更年期综合症患者少食动物油及肥肉，可用植物油代替。\n",
      "**************************************************\n",
      "维生素A原的良好来源是富含B一胡萝卜素的黄绿色蔬菜和水果，如西蓝花、胡萝卜、红薯、茴香、荠菜、芒果等。\n",
      "**************************************************\n",
      "生玉米棒可剥去外皮，只留两三层内皮，装入保鲜袋放冰箱冷冻。冷冻后的鲜玉米煮制时不必解冻，直接入锅煮即可。\n",
      "**************************************************\n",
      "宜少盐少糖。咳嗽严重者应慎食酸甜水果。\n",
      "**************************************************\n",
      "家长可以培养青少年选择一些水果、坚果、奶制品、谷薯类等，作为营养和能量的补充。\n",
      "**************************************************\n",
      "因此应特别关注农村地区居民的营养与健康问题，在解决营养不良的同时，强调预防和控制慢性病的快速增长。\n",
      "**************************************************\n",
      "维生素E具有很强的抗氧化作用，可以防止细胞老化，具有抗衰老的效果。\n",
      "**************************************************\n",
      "熟吃能够充分吸收胡萝卜素，胡萝卜素是脂溶性物质，和番茄里的番茄红素一样，只有在烹调时适当放油，才会大大提高胡萝卜素的吸收率。\n",
      "**************************************************\n",
      "经常流鼻涕、鼻塞可以多食肉类、鱼类、蛋类等含有蛋白质的食物来增强体质\n",
      "**************************************************\n",
      "燕麦煮饭口感不好，很少用其单独煮饭。一般在煮米饭时加点燕麦粒，和大米按比例蒸煮，既有营养，又改善了口感。\n",
      "**************************************************\n",
      "记忆力衰退患者推荐的食物有卷心菜、鸡蛋、三文鱼、黄豆及其制品、核桃、金针菇\n",
      "**************************************************\n",
      "同时还具有清热祛火的功效，夏季应多吃蘘荷。\n",
      "**************************************************\n",
      "晚餐：最佳的进餐时间为18：00点，晚餐后运动量相对减少，可减少蛋白质脂肪类食物的摄入，晚餐吃八分饱即可。\n",
      "**************************************************\n",
      "香蕉不适合放进冰箱中冷藏保存，香蕉皮会发黑，容易腐烂。把香蕉放入干净的塑料袋中，再放入1~2个苹果，挤出袋内的空气，扎紧袋口，放在阴凉、干燥处，这样能使香蕉保鲜1周左右。\n",
      "**************************************************\n",
      "豆腐皮中富含钙和钾等矿物质以及维生素B1、维生素B2、维生素E,能促进消化和吸收。\n",
      "**************************************************\n",
      "B族维生素（豆类、绿叶蔬菜）可促进肠胃蠕动，增强肠道的紧张力，防止大便千结。\n",
      "**************************************************\n",
      "EPA、DHA存在于鱼油当中，在食用竹荚鱼时，建议选择煮汤或腌制的方法，能够将鱼油一同食用。\n",
      "**************************************************\n",
      "这种成分能促进人体对维生素B的吸收，缓解身体疲劳，促进新陈代谢。\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**************************************************\n",
      "咽喉痛、声音嘶哑等症状可以摄入多维生素A，使咽喉黏膜更加强健。\n",
      "**************************************************\n",
      "肥胖指体内脂肪堆积过多和分布异常，肥胖常伴有多种代谢异常，是高血压、糖尿病、心脑血管等疾病的重要危险因素。\n",
      "**************************************************\n",
      "眼睛疲劳需要补充花青素。\n",
      "**************************************************\n",
      "新鲜的虾色泽正常，表面有光泽。虾体完整，头尾连接紧密，壳肉紧贴，触摸硬而有弹性，颜色发红。身软的虾不新鲜，不宜选购。\n",
      "**************************************************\n",
      "鸡蛋富含人体所需的氨基酸，蛋黄富含卵磷脂，适合脑力工作者。\n",
      "**************************************************\n",
      "糖尿病应该控制总热量。通过饮食摄入的总热量是影响血糖变化的重要因素，所以必须限制每日从食物中摄入的总热量，要做到控制进食量、少吃肉、多吃蔬菜、适当吃水果。\n",
      "**************************************************\n",
      "更年期的人不宜饮酒过多。\n",
      "**************************************************\n",
      "产后24小时内，在经过了术后6小时的禁食后，胃肠功能恢复，可以给予少量的流质食物，如萝卜汤，既能促进肠胃蠕动，又能促进排气、通便，减少腹胀。产后2~3天，可以适当改为半流食。\n",
      "**************************************************\n",
      "海带外表覆盖着一层类似白霜的物质，那是重要的营养成分一甘露醇，该物质具有降压利尿和消肿的作用，在解酒、减肥方面也有一定的效果，在买干海带时应选择白霜多的。\n",
      "**************************************************\n",
      "黑木耳多与蔬菜、荤菜搭配，炒、煮、煨、炖均可，还有一种吃法就是凉拌，用芥末油或醋、蒜拌好后食用。\n",
      "**************************************************\n",
      "因为钙不仅仅构建了骨骼，人体几乎所有的生命活动都离不开钙的支持，心脏的跳动、肌肉的收缩、消化的进行、激素的分泌甚至大脑的活动，都需要它的参与。\n",
      "**************************************************\n",
      "酒精摄入可增加乳腺癌的发病风险。\n",
      "**************************************************\n",
      "新妈妈在分娩后1~2天，胃口都会不太好，可以吃清淡、有营养、易消化的食物，坚持少食多餐，减肠胃的负担。\n",
      "蓝莓含有膳食纤维\n",
      "**************************************************\n",
      "蓝莓中含有大量膳食纤维，能改善肠道环境。\n",
      "**************************************************\n",
      "Ω-3脂肪酸对神经系统有保护作用，有助于健脑。研究表明，鱼类中富含Ω-3脂肪酸，吃鱼有助于加强神经细胞的活跃程度，从而提高学习和记忆能力。\n",
      "**************************************************\n",
      "2014年，Esposito等纳入18项队列研究的Meta分析结果提示合理膳食模式可使糖尿病发生风险降低20%。\n",
      "**************************************************\n",
      "我国居民膳食结构以谷物为主，但谷物以精制米面为主，全谷物及杂粮摄入不足，只有20%左右的成人能达到日均50g以上；品种多为小米和玉米，还需更为丰富；\n",
      "**************************************************\n",
      "维生素A也能提高人体免疫力，具有预防感冒等传染性疾病的功效。\n",
      "**************************************************\n",
      "核桃仁表面的褐色薄皮有苦味，有些人会把它剥掉，这样就会损失掉一部分营养，所以烹调或食用核桃仁时不要剥掉这层薄皮。\n",
      "**************************************************\n",
      "白菜中维生素和膳食纤维含量高，切的时候宜顺其纹理切，这样可减少维生素和膳食纤维的损失，并且相对易熟。烹调的时候加点醋，可减少白菜中维生素C的损失。\n",
      "**************************************************\n",
      "缺铁性贫血的人应该积极摄取构成血红蛋白的铁\n",
      "**************************************************\n",
      "维生素A可保护皮肤和黏膜\n",
      "**************************************************\n",
      "汇总多项研究的Meta分析结果显示，烟熏食品摄入增加胃癌的发病风险87%，其中，中国人群胃癌风险增加103%。\n",
      "**************************************************\n",
      "痛风患者每天饮水不少于2000毫升。为了促进尿酸的排出，痛风患者每天的饮水量必须大于2000毫升；在痛风急性发作期，要求每天饮水3000毫升以上，以保证每日的排尿量不少于2000毫升。\n",
      "**************************************************\n",
      "鸡肉在肉类食品中是比较容易变质的，购买之后要马上放进冰箱里。如果是冷藏保存，可保鲜2~3天；如果是冷冻保存，可存放8个月左右。\n",
      "**************************************************\n",
      "秋刀鱼脂肪中含有丰富的EPA,能降低胆固醇值预防血栓。特别是当季的秋刀鱼，营养价值和味道与其他时候相比有显著提升。\n",
      "**************************************************\n",
      "而且水果中的柑橘和苹果以及蔬菜中的葱类、胡萝卜、十字花科和绿叶蔬菜具有更好的效果。\n",
      "**************************************************\n",
      "葡萄柚中还富含柠檬酸，能够缓解疲劳。\n",
      "**************************************************\n",
      "但以蔬菜，尤其是绿色叶菜，以及菌藻类、薯类、水果、豆类为最好。\n",
      "蘑菇含有谷氨酸\n",
      "**************************************************\n",
      "蘑菇中含有大量谷氨酸，是蘑菇中的香味成分。人体摄入后能集中注意力以及增强记忆力。\n",
      "**************************************************\n",
      "煮大米饭时可以适量加点粗杂粮，食物多样化，以均衡营养。\n",
      "**************************************************\n",
      "橘子抗氧化维生素保护肌肤健康，预防癌症\n",
      "**************************************************\n",
      "肥胖人群应该控制碳水化合物的摄入\n",
      "**************************************************\n",
      "香菇富含硒元素，能有效清除体内的自由基，增强人体免疫功能。\n",
      "虾包含甜菜碱\n",
      "**************************************************\n",
      "虾中还包含甜菜碱，这一成分具有维持体温的作用。\n",
      "**************************************************\n",
      "不同部位脂肪含量不同。鸡胸脯肉的脂肪含量很低，而且含有大量维生素，鸡翅膀却含有较多脂肪，想减肥的人和血脂高的人应尽量少吃。\n",
      "**************************************************\n",
      "蛋白质和维生素C能有效缓解缺铁性贫血。\n",
      "**************************************************\n",
      "虽然胆固醇高的人要避免食用鸡蛋，但蛋类能保证体内卵磷脂与胆固醇值正常，因此胆固醇高的人也无须担心。\n",
      "**************************************************\n",
      "小竹荚鱼可以选择油炸的方法，连同鱼骨头一起食用，有利于补充钙质。\n",
      "**************************************************\n",
      "各种汤羹，比如白菜粉丝汤、银耳羹、雪梨羹、排骨汤、牛肉番茄汤等，既能补水又能补营养，只是在制作过程中要少加油、盐、糖\n",
      "**************************************************\n",
      "2015年，一项队列研究发现，在男性中，较长时间和较高的平均饮酒量与结直肠癌风险升高相关（与不饮酒者相比，饮酒时间≥30年的人群发生结直肠癌的风险增加93%；饮酒量≥30g/d的发病风险增加124%)。\n",
      "**************************************************\n",
      "荟萃分析分析结果表明，每天一杯(236.6ml)茶使心血管疾病的死亡风险平均降低4%；\n",
      "**************************************************\n",
      "我国大多数人群膳食结构仍保持植物性为主，谷类食物仍是能量的主要食物来源，蔬菜供应品种更加丰富，季节性差异明显缩小，居民蔬菜摄入量仍稳定在人均每日270g左右，与其他国家相比一直处于较好的水平。\n",
      "**************************************************\n",
      "毛豆中的胡萝卜素具有抗氧化作用，能防止身体衰老。\n",
      "**************************************************\n",
      "糖尿病：低糖低脂高纤维\n",
      "**************************************************\n",
      "虾青素除了能提高人体免疫力，还具有防癌的功效。\n",
      "**************************************************\n",
      "优质西瓜体型匀称，瓜皮为绿色、色泽深，纹路明显，瓜脐四周饱满、中间凹陷；用手摸瓜皮，皮滑且硬；用手轻拍瓜身，声音较沉闷。\n",
      "**************************************************\n",
      "中国不同人群的研究显示，保持平衡膳食模式可以降低2型糖尿病、妊娠糖尿病、代谢综合征、乳腺癌、冠心病和非酒精性脂肪肝的发病风险，并可降低人群的全因死亡风险。\n",
      "**************************************************\n",
      "心情急躁、紧张不安时推荐多食猪肉来补充维生素B1。\n",
      "韭菜来源于硫化丙烯基\n",
      "**************************************************\n",
      "韭菜的香味来源于其中所含的硫化丙烯基。它能预防感冒，促进血液循环，维持体温\n",
      "**************************************************\n",
      "白萝卜宜分段食用：白萝卜从顶部至3~5厘米处为第一段，此段维生素C含量最多，宜切丝、条，快速烹调；和羊肉一起做馅，味道极佳。\n",
      "**************************************************\n",
      "除孕妇外，成年人、老年人不宜用骨头汤补钙。\n",
      "**************************************************\n",
      "眼睛疲劳推荐摄取维生素A和花青素\n",
      "**************************************************\n",
      "谷类包含碳水化合物、膳食纤维、B族维生素、蛋白质、矿物质等营养物质\n",
      "**************************************************\n",
      "过多摄入含糖饮料可增加儿童、成年人肥胖或体重增加的发生风险。\n",
      "**************************************************\n",
      "高血压患者应该控制饮食中盐分的摄入，多摄取富含于蔬菜、水果及海藻等食物中的钾。\n",
      "**************************************************\n",
      "白果具有敛肺气、定喘咳的功效，对于肺病咳嗽、老人体虚哮喘及各种哮喘痰多症均有辅助食疗作用。\n",
      "**************************************************\n",
      "脂肪肝患者严格限制食用油炸、油煎的食物，烹调方法宜采用蒸、煮、烩、炖、熬等。\n",
      "**************************************************\n",
      "魔芋是低能量食物，同时还能改善便秘，是很好的减肥食品。\n",
      "**************************************************\n",
      "营养素可分为很多种类，其中糖类（碳水化合物入脂质、蛋白质称为三大营养素，再加上维生素与矿物质，合称为五大营养素。\n",
      "**************************************************\n",
      "因此，应多食用含铁质丰富的食物如猪肝、海带、鱼肉、牛肉等。\n",
      "**************************************************\n",
      "腹泻患者需要及时补充维生素C(如石榴、樱桃等)。\n",
      "**************************************************\n",
      "高钙食物有芹菜、菜花、甘蓝、紫菜、黄豆、豆腐、牛奶、酸奶等。\n",
      "**************************************************\n",
      "高摄入水果、蔬菜、坚果类的“南方传统膳食模式”与高血压发病率呈负相关，在该膳食模式上得分最高的四分位人群与最低的四分位人群相比，高血压风险下降27%。\n",
      "**************************************************\n",
      "蔬菜和水果总量摄入增加可使肺癌发病风险降低24%。\n",
      "**************************************************\n",
      "红豆中含有张气因子，容易在肠道产气，使人有胀气的感觉。在煮红豆时加少许盐，有助于缓解胀气。\n",
      "**************************************************\n",
      "多吃蔬菜和水果，有利于血脂异常患者。蔬菜和水果可提供丰富的维生素C、维生素E及胡萝卜素、番茄红素等天然抗氧化剂，可以防止坏胆固醇（低密度脂蛋白胆固醇)氧化、堆积，有利于降血脂。\n",
      "**************************************************\n",
      "少食多餐。将一日三餐改为5餐或6餐可避免一次饮食过多而导致血糖猛然升高，但加餐的食物也要计算在总热量里。牛奶、鸡蛋、豆腐干等蛋白质类食物，以及黄瓜、番茄、梨等低热量蔬果都是加餐的好选择。\n",
      "**************************************************\n",
      "切成方块状。将西瓜横向对半切开，取其中一半切成2厘米厚的片状；将瓜皮与瓜瓤分离，按照适合自己一口吃下的大小切成方块状。\n",
      "**************************************************\n",
      "每天摄入300克奶或相当量的奶制品就能较好地补充钙，对于预防骨质疏松非常关键。奶类还是优质蛋白质和B族维生素的良好来源。\n",
      "**************************************************\n",
      "然而，各类粗杂粮在经过去皮、磨粉、过罗，添加饱和脂肪酸过多的动物油脂、糖甚至色素，再经过蒸煮甚至油炸之后，营养功效大打折扣。\n",
      "**************************************************\n",
      "新鲜鸡肉肉质紧密，颜色呈粉红色，有光泽，鸡皮为米色且有光泽，毛囊突出。\n",
      "**************************************************\n",
      "高血压患者需要多补充钾、钙、水、膳食纤维等营养素\n",
      "**************************************************\n",
      "油、盐是烹饪的主要调味品，是每天都离不开的，但现状是大家吃油太多，吃盐太多，各种添加糖摄入过多，饮酒没有限制，以至于高脂血症、高血压、糖尿病、脂肪肝等慢性病越来越多。\n",
      "**************************************************\n",
      "土豆富含淀粉、钾、维生素C、B族维生素，其中的淀粉生糖速度相对较慢，更抗饿。\n",
      "**************************************************\n",
      "紫色：富含美颜花青素，如茄子、紫甘蓝、洋葱等\n",
      "**************************************************\n",
      "怀孕期间孕吐较明显的孕妇，可根据个人饮食爱好和口味选择清淡适口、容易消化的食物，少量多餐，尽可能多地摄入食物，特别是富含碳水化合物的谷薯类食物。\n",
      "COO\n",
      "**************************************************\n",
      "橘子橙色果肉部分中含有β-胡萝卜素和β-隐黄素等抗氧化维生素。\n",
      "**************************************************\n",
      "孕吐反应一般发生在孕早期，这是由于孕妈体内激素水平发生了较大变化，机体需要经历一系列的调整过程。\n",
      "**************************************************\n",
      "肾结石患者需要多补水，适当补钾和镁，有以下的症状腰腹部绞痛、恶心、呕吐、烦躁不安、腹痛、血尿\n",
      "**************************************************\n",
      "保存鲜虾的最好方法是冷冻，把虾洗干净，放进塑料保鲜盒中，倒入没过虾的清水，盖上盖子，送进冰箱冷冻。可使虾保鲜3个月左右。冻虾必须放水，不放水虾的颜色很快就发黑了。\n",
      "**************************************************\n",
      "而且油菜中维生素C含量较多，摄入后能提高人体免疫力。\n",
      "**************************************************\n",
      "感冒起始应多喝白开水或淡的绿茶，后期应适量增加新鲜水果的摄入量。\n",
      "**************************************************\n",
      "植物油是从大豆、橄榄、玉米、葵花籽等植物种子中提炼而成。\n",
      "**************************************************\n",
      "青花鱼背部稍微发黑的肉中含有铁和EPA等促进血液循环的成分，应连同这部分鱼肉一起食用，能有效防止血栓和动脉硬化。\n",
      "**************************************************\n",
      "老年人需要做到少食多餐、清淡细软\n",
      "**************************************************\n",
      "例如，1982年17岁农村男生身高平均值是159.8cm,到2017年为170.3cm。\n",
      "**************************************************\n",
      "脂肪肝患者应控制碳水化合物的摄入量，特别应注意少吃富含蔗糖、果糖、葡萄糖等的食物，以防热量过剩转化为脂肪。\n",
      "**************************************************\n",
      "虽然我国居民添加糖摄入水平不高，但作为添加糖的主要来源，含糖饮料消费人群比例及其消费量均呈快速上升趋势，高糖摄入已成为青少年肥胖、糖尿病高发的主要危险因素，控制青少年糖的摄入是促进青少年健康成长的关键。\n",
      "**************************************************\n",
      "眼睛疲劳的必需营养素有维生素A、B族营养素、花青素、优质蛋白质\n",
      "**************************************************\n",
      "山药蒸着吃，原汁原味，没有其他添加物，营养价值能很好地保存，有效成分也不易被破坏。\n",
      "**************************************************\n",
      "花蛤中含有丰富的钙质能安定精神。同时还具有利尿作用，能消除身体水肿。\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**************************************************\n",
      "水果中丰富的维生素C和坚果中的维生素也可以有效缓解头痛\n",
      "**************************************************\n",
      "膳食组合或结构的不同，或某些食物长期过多过少，将造成所供给的能量或营养素与机体需要之间不平衡的状态，有充足证据说明，膳食因素与机体免疫水平、慢性病的发生风险有密切关系。\n",
      "**************************************************\n",
      "此外，维生素C、维生素E以及B族维生素也有缓解头痛的作用。\n",
      "**************************************************\n",
      "此外，薯类还普遍含有抗氧化成分，比如紫薯含花青素，山药和红薯等膳食纤维含量高，可预防便秘、肠癌。\n",
      "COO\n",
      "COO\n",
      "COO\n",
      "**************************************************\n",
      "胚芽部分富含维生素B1、维生素E、亚油酸、膳食纤维。其中，维生素E具有抗氧化作用，亚油酸能预防动脉硬化，膳食纤维能防止便秘。\n",
      "**************************************************\n",
      "高血压患者需要补钾和多吃富含膳食纤维的食物\n",
      "**************************************************\n",
      "青花鱼中含有的牛磺酸能保护胃的健康，还具有增强体力的功效。\n",
      "**************************************************\n",
      "豆腐渣中还富含卵磷脂，能提高记忆力。\n",
      "**************************************************\n",
      "鸡蛋如果常温存放，冬季时可存放15天，夏季可存放10天。如果放进冰箱冷藏，要把鸡蛋的大头朝上小头朝下存放，可保鲜1个月左右。\n",
      "**************************************************\n",
      "鱼肉含有优质蛋白质，而且脂肪里含有大量的不饱和脂肪酸，如EPA、DHA,能够促进大脑发育、保护视力，对眼睛有益。\n",
      "**************************************************\n",
      "新鲜苹果色泽美观，表面光滑完整：成熟的苹果有果香味，果肉质地紧密，用手在表面轻轻按压无凹陷。\n",
      "**************************************************\n",
      "为了控制脂肪的摄入量，应尽量选择含脂肪较少的食物。如选用瘦肉代替肥肉或五花肉，选用低脂的鱼、兔肉代替猪、羊肉；\n",
      "**************************************************\n",
      "柿子具有抗癌作用，富含维生素C\n",
      "**************************************************\n",
      "有粉刺的人多食用（猪、牛等的）肝脏以及牡蛎、海苔等食物\n",
      "**************************************************\n",
      "从监测数据来看，我国5岁以下儿童生长迟缓率、低体重率分别为4.8%和1.9%，已实现2020年规划预设目标。\n",
      "**************************************************\n",
      "人体内的维生素对于保持认知能力至关重要。\n",
      "竹笋含有纤维素\n",
      "**************************************************\n",
      "竹笋中含有不可溶性膳食纤维的纤维素，通过吸收肠道内的水分而变得膨胀，更好地排出肠道内的有害物质。\n",
      "**************************************************\n",
      "骨质疏松患者注重镁的补充。\n",
      "**************************************************\n",
      "在海藻类中，羊栖菜的铁和钙含量都是最高的。\n",
      "**************************************************\n",
      "在肉类当中，牛肉的铁含量较为丰富，食用牛肉能改善贫血。\n",
      "**************************************************\n",
      "一般持续灭菌乳，可放在家里干燥、凉爽、避光的地方保存：打开包装的牛奶应及时喝掉；或者密封好放在冰箱内储存。\n",
      "**************************************************\n",
      "要选外皮略深、呈土黄色的、整体软硬一致（不要局部软的）的猕猴桃，并且最好选尖头的，不要扁头的，这样的比较甜。\n",
      "**************************************************\n",
      "中医学认为，白萝卜性凉，味甘、辛，具有润肺、止咳、化痰的作用。\n",
      "**************************************************\n",
      "维生素D与钙不可分割。要知道“补钙”与“钙吸收”是两回事，补钙的同时需要补充可促进钙吸收的维生素D,使钙质被充分吸收与利用。\n",
      "**************************************************\n",
      "素食人群，黄豆及其豆制品是优质蛋白质的主要来源。\n",
      "**************************************************\n",
      "花青素保护眼睛健康\n",
      "**************************************************\n",
      "系统综述结果显示，少量（酒精≤12.5g/d)、适量（酒精12.6~37.4g/d)、过量（酒精≥37.5g/d)饮酒都能增加痛风的发病风险，其发病风险分别为不饮酒者的1.16倍、1.58倍和2.64倍。\n",
      "**************************************************\n",
      "番茄所含的苹果酸、柠檬酸等有机酸，能促使胃液分泌，增加胃酸浓度，调整胃肠功能，有助于胃肠疾病的康复。\n",
      "**************************************************\n",
      "造成洋葱特殊的辣味以及切洋葱时引起流泪的原因是洋葱中含有一种硫化丙烯基的成分。\n",
      "**************************************************\n"
     ]
    }
   ],
   "source": [
    "def parse_dep(cws, dep_head, dep_label):\n",
    "    result = []\n",
    "    for idx in range(len(cws)+1):\n",
    "        if idx == 0:\n",
    "            result.append({\n",
    "                \"name\": 'root',\n",
    "                \"to\": [],\n",
    "                \"in\": []\n",
    "            })\n",
    "        else:\n",
    "            result.append({\n",
    "                \"name\": cws[idx - 1],\n",
    "                \"to\": [],\n",
    "                \"in\": []\n",
    "            })\n",
    "\n",
    "    for cws_idx, in_idx in enumerate(dep_head):\n",
    "        result[cws_idx + 1][\"in\"].append({\n",
    "            \"idx\": in_idx,\n",
    "            \"name\": cws[in_idx - 1],\n",
    "            \"label\": dep_label[cws_idx]\n",
    "        })\n",
    "        result[in_idx][\"to\"].append({\n",
    "            \"idx\": cws_idx + 1,\n",
    "            \"name\": cws[cws_idx],\n",
    "            \"label\": dep_label[cws_idx]\n",
    "        })\n",
    "    return result\n",
    "\n",
    "def create_words(label):\n",
    "        words = []\n",
    "        disease_words = []\n",
    "        nutrient_words = []\n",
    "        crowd_words = []\n",
    "        food_words = []\n",
    "        organ_words = []\n",
    "        for key in list(label.keys()):\n",
    "            if key == 'food':\n",
    "                food_words = [word for word in label[key]]\n",
    "            elif key == 'disease':\n",
    "                disease_words = [word for word in label[key]]\n",
    "            elif key == 'nutrient':\n",
    "                nutrient_words = [word for word in label[key]]\n",
    "            elif key == 'crowd':\n",
    "                crowd_words = [word for word in label[key]]\n",
    "            elif key == 'organ':\n",
    "                organ_words = [word for word in label[key]]\n",
    "            for word in label[key]:\n",
    "                words.append(word)\n",
    "        return (words, disease_words, nutrient_words, crowd_words, food_words, organ_words)\n",
    "\n",
    "with open(r'./train.json', 'r') as f:\n",
    "    for i in f.readlines()[:300]:\n",
    "        try:\n",
    "            print(text)\n",
    "            data = eval(i)\n",
    "            text = data['text']\n",
    "            label = data['label']\n",
    "            words, disease_words, nutrient_words, crowd_words, food_words, organ_words = create_words(label)\n",
    "            ltp.add_words(words)\n",
    "            \n",
    "            result = ltp.pipeline([text], tasks = [\"cws\",\"dep\"])\n",
    "\n",
    "            cws = result.cws[0]\n",
    "            dep = result.dep[0]\n",
    "            dep_head = dep['head']\n",
    "            dep_label = dep['label']\n",
    "            parsed_dep = parse_dep(cws, dep_head, dep_label)\n",
    "\n",
    "            root = parsed_dep[parsed_dep[0][\"to\"][0]['idx']]\n",
    "\n",
    "            cur_n = []\n",
    "            cur_f = []\n",
    "            for root_to in root[\"to\"]:\n",
    "                if root_to['label'] == \"VOB\" and root_to[\"name\"] in nutrient_words:\n",
    "                    cur_n.append([root[\"name\"], root_to[\"name\"]])\n",
    "                    root_to_entity = parsed_dep[root_to['idx']]\n",
    "                    for root_to_to in root_to_entity[\"to\"]:\n",
    "                        if root_to_to['label'] == 'COO':\n",
    "                            print(\"COO\")\n",
    "                            cur_n.append([root[\"name\"], root_to_to[\"name\"]])\n",
    "\n",
    "                if root_to['label'] == \"SBV\":\n",
    "                    SBV_idx = root_to['idx']\n",
    "                    for entity in parsed_dep[SBV_idx][\"to\"]:\n",
    "                        if entity['name'] in food_words:\n",
    "                            cur_f.append([entity['name'], root[\"name\"]])\n",
    "            \n",
    "            for f in cur_f:\n",
    "                for n in cur_n:\n",
    "                    if f[1] == n[0]:\n",
    "                        print(f[0] + f[1] + n[1])\n",
    "\n",
    "        except:\n",
    "            print(\"error:\"+text)\n",
    "        print(\"*\"*50)\n",
    "#         break\n",
    "       "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('牛奶', '含有', '维生素B2')\n",
      "('牛奶', '含有', '铁')\n",
      "('牛奶', '含有', '维生素A')\n",
      "('牛奶', '含有', '蛋白质')\n",
      "('牛奶', '含有', '钙')\n"
     ]
    }
   ],
   "source": [
    "result = ltp.pipeline([\"牛奶含有蛋白质、钙、铁、维生素A、维生素B2\"], tasks = [\"cws\",\"dep\"])\n",
    "\n",
    "parsed_dep = parse_dep(result.cws[0], result.dep[0]['head'], result.dep[0]['label'])\n",
    "\n",
    "fo = get_root_to_food(parsed_dep, ['牛奶'])\n",
    "nu = get_root_to_nutrient(parsed_dep, ['蛋白质', '钙', '铁', '维生素A', '维生素B2'])\n",
    "\n",
    "root = parsed_dep[parsed_dep[0]['to'][0]['idx']]\n",
    "for i in nu:\n",
    "    print((fo, root['name'], i))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pprint import pprint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Loading weights from local directory\n",
      "[('芋头', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[('牡蛎', '是', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('全谷', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('海带', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('黄豆', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('黄豆', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('芝麻', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('芝麻', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('裙带菜', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[('牛奶', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('牛奶', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('牛奶', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('牛奶', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('牛奶', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('罗勒', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('水果', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('水果', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('水果', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('水果', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('水果', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('黄瓜', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('胡萝卜', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('明日叶', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('黄豆', '含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('茄子', '含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('裙带菜', '含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('鸡蛋', '含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('蓝莓', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('蘑菇', '含有', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('虾', '包含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('韭菜', '来源于', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n",
      "[('谷类', '包含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('谷类', '包含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('谷类', '包含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('谷类', '包含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙']),\n",
      " ('谷类', '包含', ['维生素B2', '铁', '维生素A', '蛋白质', '钙'])]\n",
      "[]\n",
      "[]\n",
      "[]\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-88-1b6f8cf450cb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m     39\u001b[0m     \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreadlines\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m300\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     40\u001b[0m         \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0meval\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m         \u001b[0mextract_one_sentence\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mltp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m<ipython-input-88-1b6f8cf450cb>\u001b[0m in \u001b[0;36mextract_one_sentence\u001b[0;34m(data, ltp)\u001b[0m\n\u001b[1;32m     27\u001b[0m     \u001b[0mltp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd_words\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwords\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     28\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 29\u001b[0;31m     \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mltp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpipeline\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mtext\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtasks\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m\"cws\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"dep\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     30\u001b[0m     \u001b[0mparsed_dep\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparse_dep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcws\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdep\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'head'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdep\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'label'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     31\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.7/site-packages/ltp/nerual.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m     24\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     25\u001b[0m         \u001b[0;32mwith\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mno_grad\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m             \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     27\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     28\u001b[0m     \u001b[0;32mreturn\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.7/site-packages/ltp/nerual.py\u001b[0m in \u001b[0;36mpipeline\u001b[0;34m(self, inputs, tasks, raw_format, return_dict)\u001b[0m\n\u001b[1;32m    155\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    156\u001b[0m         \u001b[0mmodel_kwargs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdevice\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mtokenized\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 157\u001b[0;31m         \u001b[0moutputs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbackbone\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0mmodel_kwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    158\u001b[0m         \u001b[0mcache\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    159\u001b[0m         hidden = {\n",
      "\u001b[0;32m/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py\u001b[0m in \u001b[0;36m_call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m    720\u001b[0m             \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_slow_forward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    721\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 722\u001b[0;31m             \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mforward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    723\u001b[0m         for hook in itertools.chain(\n\u001b[1;32m    724\u001b[0m                 \u001b[0m_global_forward_hooks\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.7/site-packages/transformers/models/electra/modeling_electra.py\u001b[0m in \u001b[0;36mforward\u001b[0;34m(self, input_ids, attention_mask, token_type_ids, position_ids, head_mask, inputs_embeds, encoder_hidden_states, encoder_attention_mask, past_key_values, use_cache, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m    921\u001b[0m             \u001b[0moutput_attentions\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0moutput_attentions\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    922\u001b[0m             \u001b[0moutput_hidden_states\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0moutput_hidden_states\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 923\u001b[0;31m             \u001b[0mreturn_dict\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mreturn_dict\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    924\u001b[0m         )\n\u001b[1;32m    925\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py\u001b[0m in \u001b[0;36m_call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m    720\u001b[0m             \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_slow_forward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    721\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 722\u001b[0;31m             \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mforward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    723\u001b[0m         for hook in itertools.chain(\n\u001b[1;32m    724\u001b[0m                 \u001b[0m_global_forward_hooks\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.7/site-packages/transformers/models/electra/modeling_electra.py\u001b[0m in \u001b[0;36mforward\u001b[0;34m(self, hidden_states, attention_mask, head_mask, encoder_hidden_states, encoder_attention_mask, past_key_values, use_cache, output_attentions, output_hidden_states, return_dict)\u001b[0m\n\u001b[1;32m    586\u001b[0m                     \u001b[0mencoder_attention_mask\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    587\u001b[0m                     \u001b[0mpast_key_value\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 588\u001b[0;31m                     \u001b[0moutput_attentions\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    589\u001b[0m                 )\n\u001b[1;32m    590\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.7/site-packages/torch/nn/modules/module.py\u001b[0m in \u001b[0;36m_call_impl\u001b[0;34m(self, *input, **kwargs)\u001b[0m\n\u001b[1;32m    720\u001b[0m             \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_slow_forward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    721\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 722\u001b[0;31m             \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mforward\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0minput\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    723\u001b[0m         for hook in itertools.chain(\n\u001b[1;32m    724\u001b[0m                 \u001b[0m_global_forward_hooks\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.7/site-packages/transformers/models/electra/modeling_electra.py\u001b[0m in \u001b[0;36mforward\u001b[0;34m(self, hidden_states, attention_mask, head_mask, encoder_hidden_states, encoder_attention_mask, past_key_value, output_attentions)\u001b[0m\n\u001b[1;32m    507\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    508\u001b[0m         layer_output = apply_chunking_to_forward(\n\u001b[0;32m--> 509\u001b[0;31m             \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfeed_forward_chunk\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mchunk_size_feed_forward\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mseq_len_dim\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mattention_output\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    510\u001b[0m         )\n\u001b[1;32m    511\u001b[0m         \u001b[0moutputs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mlayer_output\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0moutputs\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.7/site-packages/transformers/pytorch_utils.py\u001b[0m in \u001b[0;36mapply_chunking_to_forward\u001b[0;34m(forward_fn, chunk_size, chunk_dim, *input_tensors)\u001b[0m\n\u001b[1;32m    213\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    214\u001b[0m     \u001b[0;31m# inspect.signature exist since python 3.5 and is a python method -> no problem with backward compatibility\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 215\u001b[0;31m     \u001b[0mnum_args_in_forward_chunk_fn\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minspect\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msignature\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mforward_fn\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparameters\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    216\u001b[0m     \u001b[0;32mif\u001b[0m \u001b[0mnum_args_in_forward_chunk_fn\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minput_tensors\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    217\u001b[0m         raise ValueError(\n",
      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "def create_words(label):\n",
    "    words = []\n",
    "    disease_words = []\n",
    "    nutrient_words = []\n",
    "    crowd_words = []\n",
    "    food_words = []\n",
    "    organ_words = []\n",
    "    for key in list(label.keys()):\n",
    "        if key == 'food':\n",
    "            food_words = [word for word in label[key]]\n",
    "        elif key == 'disease':\n",
    "            disease_words = [word for word in label[key]]\n",
    "        elif key == 'nutrient':\n",
    "            nutrient_words = [word for word in label[key]]\n",
    "        elif key == 'crowd':\n",
    "            crowd_words = [word for word in label[key]]\n",
    "        elif key == 'organ':\n",
    "            organ_words = [word for word in label[key]]\n",
    "        for word in label[key]:\n",
    "            words.append(word)\n",
    "    return (words, disease_words, nutrient_words, crowd_words, food_words, organ_words)\n",
    "\n",
    "def extract_one_sentence(data, ltp):\n",
    "    text = data['text']\n",
    "    label = data['label']\n",
    "    words, disease_words, nutrient_words, crowd_words, food_words, organ_words = create_words(label)\n",
    "    ltp.add_words(words)\n",
    "\n",
    "    result = ltp.pipeline([text], tasks = [\"cws\",\"dep\"])\n",
    "    parsed_dep = parse_dep(result.cws[0], result.dep[0]['head'], result.dep[0]['label'])\n",
    "\n",
    "    result = []\n",
    "#     result = result + get_food_to_nutient(parsed_dep, food_words, nutrient_words)\n",
    "    pprint(get_food_to_nutient(parsed_dep, food_words, nutrient_words))\n",
    "    return result\n",
    "\n",
    "ltp = LTP(\"/Users/lazyben/Downloads/small\")\n",
    "with open(r'./train.json', 'r') as f:\n",
    "    for i in f.readlines()[:300]:\n",
    "        data = eval(i)\n",
    "        extract_one_sentence(data, ltp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_food_to_nutient(parsed_dep, food_words, nuritent_words):\n",
    "    root = parsed_dep[parsed_dep[0]['to'][0]['idx']]['name']\n",
    "    food = get_root_to_food(parsed_dep, food_words)\n",
    "    nutrient = get_root_to_nutrient(parsed_dep, nuritent_words)\n",
    "    result = []\n",
    "    if food and nutrient:\n",
    "        for i in nutrient:\n",
    "            result.append((food, root, nu))\n",
    "    return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "## root to food\n",
    "def get_root_to_food(parsed_dep, food_words):\n",
    "    root = parsed_dep[parsed_dep[0]['to'][0]['idx']]\n",
    "    for ele in root['to']:\n",
    "        if ele['label'] == 'SBV':\n",
    "            if ele['name'] in food_words:\n",
    "                return ele['name']\n",
    "            else:\n",
    "                sbv = parsed_dep[ele['idx']]\n",
    "                for to in sbv['to']:\n",
    "                    if to['label'] == \"ATT\" and to['name'] in food_words:\n",
    "                        return to['name']\n",
    "    return ''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "## root to nutrient\n",
    "def get_root_to_nutrient(parsed_dep, nuritent_words):\n",
    "    VOB_ = []\n",
    "    nuritent = []\n",
    "    root = parsed_dep[parsed_dep[0]['to'][0]['idx']]\n",
    "    for ele in root['to']:\n",
    "        if ele['label'] == 'VOB':\n",
    "            if ele['name'] in nuritent_words:\n",
    "                nuritent.append(ele['name'])\n",
    "                cur_nu = parsed_dep[ele['idx']]\n",
    "                for nu in cur_nu['to']:\n",
    "                    if nu['name'] in nuritent_words:\n",
    "                        nuritent.append(nu['name'])\n",
    "            else:\n",
    "                VOB_.append(parsed_dep[ele['idx']])\n",
    "    for vob in VOB_:\n",
    "        for to in vob['to']:\n",
    "            if to['label'] == \"ATT\" and to['name'] in nuritent_words:\n",
    "                nuritent.append(to['name'])\n",
    "                cur_nu = parsed_dep[to['idx']]\n",
    "                for nu in cur_nu['to']:\n",
    "                    if nu['name'] in nuritent_words:\n",
    "                        nuritent.append(nu['name'])\n",
    "    return list(set(nuritent))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "[\n",
    "    {\n",
    "        \"name\": 'root',\n",
    "        \"to\": [{\n",
    "            \"idx\": 3,\n",
    "            \"name\": \"含有\",\n",
    "            \"label\": \"HED\"\n",
    "        }],\n",
    "        \"in\": []\n",
    "    },\n",
    "    {\n",
    "        \"name\": '芋头',\n",
    "        \"to\": [],\n",
    "        \"in\": [1]\n",
    "    }\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['O',\n",
       " 'S-Ns',\n",
       " 'S-Nh',\n",
       " 'B-Ni',\n",
       " 'E-Ni',\n",
       " 'I-Ni',\n",
       " 'S-Ni',\n",
       " 'B-Ns',\n",
       " 'E-Ns',\n",
       " 'I-Ns',\n",
       " 'B-Nh',\n",
       " 'E-Nh',\n",
       " 'I-Nh']"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ltp.ner_vocab"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "s = set()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "s.add"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch.nn as nn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [],
   "source": [
    "lstm = nn.LSTM(\n",
    "    input_size=2,\n",
    "    hidden_size=3,\n",
    "    batch_first=True,\n",
    "    num_layers=3\n",
    ")\n",
    "\n",
    "temp = torch.rand(1, 170, 2) \n",
    "out,_ = lstm(temp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "torch.Size([1, 170, 3])\n"
     ]
    }
   ],
   "source": [
    "print(out.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
